/**
 * 
 */
package scriptrunner.execution;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * @author Administrator
 * 
 */
public class EvalListDefExpr extends EvaluateExpr implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5052311593838050870L;

	/**
	 * 
	 */
	public EvalListDefExpr(EvalListContentList lcl) {
		this.lcl = lcl;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * scriptrunner.execution.EvaluateExpr#CalculateResult(scriptrunner.execution
	 * .Session)
	 */
	@Override
	public ValueObject CalculateResult(Session se) throws ExecuteErrorException {

		ValueListObject value = new ValueListObject();
		ArrayList<EvaluateExpr> evalList = lcl.GetEvaluateExprList();

		for (EvaluateExpr eval : evalList) {
			try {
				value.AddListElement(eval.CalculateResult(se));
			} catch (CloneNotSupportedException e) {
				throw new ExecuteErrorException(
						"The value cannot be cloned when it is assigned to a varible");
			}
		}

		return value;
	}

	EvalListContentList lcl;
}
